package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.CultureInfoRequest;
import cn.stylefeng.guns.modular.business.service.CultureInfoService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 社会文化控制器
 *
 * @author zhangyaowen
 * @date 2021/11/05 15:32
 */
@RestController
@ApiResource(name = "社会文化")
public class CultureInfoController {

    @Resource
    private CultureInfoService cultureInfoService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @PostResource(name = "添加", path = "/cultureInfo/add")
    public ResponseData add(@RequestBody @Validated(CultureInfoRequest.add.class) CultureInfoRequest cultureInfoRequest) {
        cultureInfoService.add(cultureInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @PostResource(name = "删除", path = "/cultureInfo/delete")
    public ResponseData delete(@RequestBody @Validated(CultureInfoRequest.delete.class) CultureInfoRequest cultureInfoRequest) {
        cultureInfoService.del(cultureInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @PostResource(name = "编辑", path = "/cultureInfo/edit")
    public ResponseData edit(@RequestBody @Validated(CultureInfoRequest.edit.class) CultureInfoRequest cultureInfoRequest) {
        cultureInfoService.edit(cultureInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "查看详情", path = "/cultureInfo/detail")
    public ResponseData detail(@Validated(CultureInfoRequest.detail.class) CultureInfoRequest cultureInfoRequest) {
        return new SuccessResponseData(cultureInfoService.detail(cultureInfoRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "获取列表", path = "/cultureInfo/list")
    public ResponseData list(CultureInfoRequest cultureInfoRequest) {
        return new SuccessResponseData(cultureInfoService.findList(cultureInfoRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "分页查询", path = "/cultureInfo/page")
    public ResponseData page(String sciFirst,String sciSecond) {
        CultureInfoRequest cultureInfoRequest = new CultureInfoRequest();
        cultureInfoRequest.setSciFirst(sciFirst);
        cultureInfoRequest.setSciSecond(sciSecond);
        return new SuccessResponseData(cultureInfoService.findPage(cultureInfoRequest));
    }

    @GetResource(name = "详细信息", path = "/cultureInfo/toReview")
    public ResponseData toReview(String id) {

        return new SuccessResponseData(cultureInfoService.toReview(id));
    }

}